<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>vue中的动画原理</title>
  <style>

    /* vue 通过给 transition 中的标签添加类来实现过渡效果 */
    .v-enter,
    .v-leave-to{
      opacity:0;
    }
    .v-enter-active,
    .v-leave-active{
      transition: opacity 1s;
    }
  </style>
</head>
<body>
  <script src="./js/vue2.js"></script>
  <div id="app">
    <transition>
      <h1 v-if="show">hello world</h1>
    </transition>
    <button @click="handleClick">切换</button>
  </div>
</body>
</html>
<script>
  var vm = new Vue({
    el:'#app',
    data: {
      show: true,
    },
    methods: {
      handleClick: function(){
        this.show = !this.show;
      }
    }
  });
</script>